package tq.com.tqteacher.view.viewhold;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

import tq.com.tqcom.net.TQPictureUpload;
import tq.com.tqcom.util.TQSystemDefine;
import tq.com.tqteacher.R;
import tq.com.tqteacher.model.TQCommentOverInfoModel;

public class TQLeaveMsgViewHold {
    private View mView;
    private ImageView header_icon;
    private TextView user_name;
    private TextView content;


    public TQLeaveMsgViewHold(View pView){
        mView = pView;
        if(mView == null)return;

        header_icon = mView.findViewById(R.id.header_icon);
        user_name = mView.findViewById(R.id.user_name);
        content = mView.findViewById(R.id.content);
    }

    public void setComment(TQCommentOverInfoModel.TQCommentInfoModel pInfoModel){
        if(pInfoModel == null)return;

        String url = TQPictureUpload.downloadPath(pInfoModel.getUserInfo().getPic());
        RequestOptions lOptions = new RequestOptions().placeholder(R.drawable.tx1).error(R.drawable.tx1).circleCrop();

        Glide.with(mView).load(url).apply(lOptions).into(header_icon);

        user_name.setText(pInfoModel.getUserInfo().getName());
        if(pInfoModel.getType() == TQSystemDefine.LeaveMsgType_video){
            content.setText("[视频信息]");
        }else if(pInfoModel.getType() == TQSystemDefine.LeaveMsgType_image){
            content.setText("[图片信息]");
        }else {
            content.setText(pInfoModel.getContent());
        }

    }
}
